/*
 * Encoder_Test.c
 *
 *  Created on: Feb 2, 2017
 *      Author: YzZe
 */

#include "Encoder_Test.h"
#include "cmsis_os.h"

void Encoder_test_vTask(void *pvParameters)
{
	portTickType xLastWakeTime;
	xLastWakeTime = xTaskGetTickCount();

	int32_t Encoder1 = 0, Encoder1_old = 0, Encoder2 = 0, Encoder2_old = 0;

	for (;;)
	{
		Encoder1 = Get_Encoder_Count(TIM2);
		Encoder2 = Get_Encoder_Count(TIM4);

		if (Encoder1 != Encoder1_old)
		{
			HAL_Printf("counter1:%d\r\n", Encoder1);

			Encoder1_old = Encoder1;
		}

		if (Encoder2 != Encoder2_old)
		{
			HAL_Printf("counter2:%d\r\n", Encoder2);

			Encoder2_old = Encoder2;
		}

		vTaskDelayUntil(&xLastWakeTime, (100 / portTICK_RATE_MS));
	}
}
